package com.geostar.constructionland.statistics.service.factory;

import com.geostar.constructionland.common.entity.statistics.UnifiedDataQueryConfig;
import com.geostar.constructionland.statistics.mapping.QueryMappedStatement;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @Author makoto_zhu
 * @Date 2020-12-18 03:24:18
 * @Description
 **/
@Component
public class MappedStatementFactory {
    @Resource
    private IParamsCustomWorker paramsCustomWorker;

    @Resource
    private ISqlCustomWorker sqlCustomWorker;

    @Resource
    private IResultCustomWorker resultCustomWorker;

    public QueryMappedStatement create(UnifiedDataQueryConfig unifiedDataQueryConfig) {
        QueryMappedStatement queryMappedStatement = new QueryMappedStatement();
        // 组装参数
        paramsCustomWorker.createParams(queryMappedStatement, unifiedDataQueryConfig);
        // 组装执行sql
        sqlCustomWorker.createSql(queryMappedStatement, unifiedDataQueryConfig);
        // 组装返回类型
        resultCustomWorker.createResult(queryMappedStatement, unifiedDataQueryConfig);
        // 组装完毕
        return queryMappedStatement;
    }

}
